<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>iCittys會員中心 - 註冊</title>
<link href="css/global.css" rel="stylesheet" type="text/css" />

</head>
<body>

<!-- 头部 -->
<div class="top">
	<div class="l">
		iCittys 會員中心
	</div>
	<div class="top_ad r">

	</div>
</div>

<!-- 导航 -->
<div class="menu">
	<span class="l">iCittys 註冊頁面!</span>
	<span class="r">
		<a href="login.html">登入</a>
		<a href="reg.html">註冊</a>		
	</span>
</div>
<div class="bottombg"></div>

<!-- 注册信息 -->
<div class="reg">

<form method="post" onsubmit="return disposal();" name="loginform">

	<div class="div_form">
		<div class="div1 l">註冊用戶名：</div>
		<div class="div2 l"><input class="div2_input" type="text" name="username" id="username" /></div>
		<div class="div3 l">3～20个合法字符(包括大小寫字母、數字)，一但註冊成功用戶名不能修改。</div>
	</div>

	<div class="div_form">
		<div class="div1 l">接受相關協議：</div>
		<div class="div2 l">
			<label><input name="radiobutton" type="radio" value="radiobutton" checked="checked" />接受</label>&nbsp;&nbsp;
			<label><input type="radio" name="radiobutton" value="radiobutton" />不接受</label>		
		</div>
		<div class="div3 l f14px"><!--<a href="">查看協議</a>--></div>
	</div>

	<div class="div_form">
		<div class="div1 l">註冊密碼：</div>
		<div class="div2 l"><input class="div2_input" name="password" type="password" id="password" /></div>
		<div class="div3 l">密碼區分大小寫，4～20个合法字符组成，請盡量使用英文字母加數字或符號的组合密碼。</div>
	</div>

	<div class="div_form">
		<div class="div1 l">重覆密碼：</div>
		<div class="div2 l"><input class="div2_input" name="pass" type="password" id="pass" /></div>
		<div class="div3 l">請再輸入一遍您上面輸入的密碼。</div>
	</div>

	<div class="div_form">
		<div class="div1 l">您的電子郵件：</div>
		<div class="div2 l"><input class="div2_input" name="email" type="text" id="email" /></div>
		<div class="div3 l">E-mail非常重要！這是我們與您聯絡的首選方式，以及接收我们的服務和取回密碼的途徑，請務必填寫真實，並確認是您最常用的電子郵件。</div>
	</div>


	<div class="div_form">
		<div class="div1 l">&nbsp;</div>
		<div class="div2 l">
			<label><input class="div2_submit" type="submit" id="Submit" name="sub" value="註 冊" /></label>
			<label><input class="div2_submit" type="reset" name="Submit" value="重 設" /></label>	
		</div>
		<div class="div3 l"></div>
	</div>

</form>

</div>




<div class="footer">
	<p>Powerd By APP-SSO</p>
	<p>技術支援：support@icittys.com </p>
</div>
<script type="text/javascript" src="http://hot.icittys.com/js/phprpc_client.js"></script>
<script type="text/javascript">
  <!--
  	var APP_SSO_URL = 'http://app-sso.appspot.com/';
	var http_response_code = {
		HTTP_RESPONSE_SIGN_NO:1,
		HTTP_RESPONSE_EMAIL_NO:2,
		HTTP_RESPONSE_EMAIL_OK:3,
		HTTP_RESPONSE_LOGIN_OK:4,
		HTTP_RESPONSE_DB_ERROR:5,
		HTTP_RESPONSE_LOGOUT_OK:6,
		HTTP_RESPONSE_DELETE_OK:7,
		HTTP_RESPONSE_DELETE_NO:8,
		HTTP_RESPONSE_UPDATE_OK:9,
		HTTP_RESPONSE_REGISTER_OK:10,
		HTTP_RESPONSE_VALIDATE_NO:11,
		HTTP_RESPONSE_VALIDATE_OK:12,
		HTTP_RESPONSE_USERNAME_NO:13,
		HTTP_RESPONSE_USERNAME_OK:14,
		HTTP_RESPONSE_PASSWORD_NO:15,
		HTTP_RESPONSE_EMAIL_EXISTS:16,
		HTTP_RESPONSE_VARIABLE_ERROR:17,
		HTTP_RESPONSE_USERNAME_EXISTS:18,
		HTTP_RESPONSE_EMAIL_NOT_EXISTS:19,
		HTTP_RESPONSE_USERNAME_NOT_EXISTS:20
	};
	
	function is_password(str)
	{
		var i, c;
		if(str.length < 5 || str.length > 19)
		{
			alert("密碼必須是6位以上,20位以下");
			return false;
		}
		for(i=0; i < str.length; i++)
		{
			c = str.charAt(i);
			if( (c < "0" || c > "9") && (c < "a" || c > "z" ) && (c < "A" || c > "Z" ))
			{
				alert("密碼必須由小寫字母或數字組成");
				return false;
			}
		}
		return true;
	}

	function match_password(pass1, pass2)
	{
		if(pass1 != pass2)
		{
			alert("兩次輸入的密碼不一樣,請重新輸入");
			return false;
		}
		return true;
	}


	function isEmail(strEmail) 
	{
		if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		{
			return true;
		}

		alert("電子郵件驗證失敗");
		return false;
	}

	function is_username(username)
	{
		//var patrn = /^[a-zA-Z0-9\u4e00-\u9fa5]{2,20}$/; 
		var patrn = /^[a-zA-Z0-9]{3,20}$/; 

		if(!patrn.exec(username))
		{
			alert("用户名必須由英文\數字");
			return false;
		}

		return true;
	}

	function check_responce_code(code)
	{
		
		switch (code)
		{
			case http_response_code.HTTP_RESPONSE_EMAIL_EXISTS :
				alert("email 已存在");
				break;
			case http_response_code.HTTP_RESPONSE_USERNAME_EXISTS :
				alert("用戶名 已存在");
				break;
			case http_response_code.HTTP_RESPONSE_USERNAME_NO :
				alert("用戶名驗證失敗");
				break;
			case http_response_code.HTTP_RESPONSE_EMAIL_NO :
				alert("電子郵件驗證失敗");
				break;
			case http_response_code.HTTP_RESPONSE_PASSWORD_NO :
				alert("密碼驗證失敗");
				break;
			case http_response_code.HTTP_RESPONSE_REGISTER_OK :
				alert("註冊成功，請至信箱收取認確信");
				var myregexp = /\?done=([^&]+)/;
				var match = myregexp.exec(location.href);
				if (match != null) {
					window.location.href = decodeURIComponent(match[1]);
				} else {
					window.location.href = "http://hot.icittys.com/member/";
				}
				break;
			default:
				alert("不知名錯誤");
		}
		
		frm = document.forms["loginform"];
		frm.elements["sub"].disabled = false;
		frm.elements["sub"].value    = "註冊";
	}


	function disposal()
	{
		var url, frm, rc;
		frm  = document.forms["loginform"];

		rc = is_username(frm.elements["username"].value);
		if(!rc) return false;
		
		rc = is_password(frm.elements["password"].value);
		if(!rc) return false;
		
		rc = match_password(frm.elements["password"].value, frm.elements["pass"].value);
		if(!rc) return false;
		
		rc = isEmail(frm.elements["email"].value);
		if(!rc) return false;

		var rpc = new PHPRPC_Client(APP_SSO_URL, ['reg']);
		rpc.reg(frm.elements["username"].value, frm.elements["password"].value, frm.elements["email"].value,function(result){
			check_responce_code(result);
		});
		frm.elements["sub"].disabled = true;
		frm.elements["sub"].value    = "正在註冊中,請稍後....";
		
		return false;
	}
  //-->
  </script>

</body>
</html>